<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue的基本代码</title>
</head>
<body>

<div id="app">
    <p>总数：{{ total }}</p>
    <my-component v-model="total"></my-component>
</div>


<script src="lib/vue-2.4.0.js"></script>
<script>

    Vue.component('my-component',{
        template: '<button @click="jiajia">+</button>',
        data() {
            return {
                count: 0
            }
        },
        methods: {
            jiajia() {
                this.count++
                this.$emit('input', this.count)
            }
        }
    })

    var vue = new Vue({
        el: '#app',
        data: {
            total: 0
        }
    })

</script>
</body>
</html>